﻿using UnityEngine;
using System.Collections;



//custom model mgr
public class ModelMgr : ZT_Object
{

    public static ModelMgr ins
    {
        get
        {
            return ModelMgr.GetInstance();
        }
    }

    private static ModelMgr _ins = null;

    public static ModelMgr GetInstance()
    {
        if (_ins == null)
        {
            _ins = new ModelMgr();
        }
        return _ins;
    }



   
    public override void OnExit()
    {
        _ins.objs.Clear();
        _ins = null;
        base.OnExit();
    }



    public ArrayList objs = new ArrayList();



    public override void UpdateMS()
    {
        BallsMgr.ins.UpdateMS();
        FoodsMgr.ins.UpdateMS();
        foreach (Model b in objs)
        {
            b.UpdateMS();
        }
    }

    public override void Update()
    {
        BallsMgr.ins.Update();
        FoodsMgr.ins.Update();

        foreach (Model b in objs)
        {
            b.Update();
        }
    }


    public void Add(Model b)
    {
        this.objs.Add(b);
    }

    public void Remove(Model b)
    {
        this.objs.Remove(b);
    }


    public static Model Create<T>() where T : new()
    {
        Model m = new T() as Model;
        m.Init();
        ins.Add(m);
        return m;
    }




}

